/* 
 *	Copyright 2014  Yanqing Wu
 *		email: yqwu_yqwu@126.com
 *
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
*/

#pragma once

#include "StdCtrlSkin_Enums.h"
#include "StdCtrlSkinCell.h"
#include "StdCtrlSkin_BaseElt.h"
#include "StdCtrlSkinAttrib.h"

/*
 *	A row in the table to manage controls
 */

class CStdCtrlSkinTable;

class CStdCtrlSkinRow : public CStdCtrlSkin_BaseElt
{
protected:
	std::map<UINT, CStdCtrlSkinCell*> m_cell_list;

	//	Back pointer to table
	CStdCtrlSkinTable* m_pTable;

public:
	CStdCtrlSkinAttrib attrib;
	UINT weight;
	UINT cols;
	UINT row;

public:
	virtual void InitDataElt(CStdCtrlSkinTable* pTable);
	CStdCtrlSkinRow(CStdCtrlSkinTable* pTable=nullptr);
	CStdCtrlSkinRow(CComPtr<IXMLDOMNode> spNode, CStdCtrlSkinTable* pTable);
	virtual ~CStdCtrlSkinRow(void);

	CString GetFilePath(void);

	//	Get width/height of each cell
	//	Format is <begin, end> - value
	//	LPARAM here is a lazy method to use start-end pair as key in map
	//	low = begin, high = end
	std::map<LPARAM, UINT> GetCellWidthStops(void);
	std::map<LPARAM, UINT> GetCellHeightStops(void);

	virtual int GetRowStart(int iRow=-1);
	virtual int GetRowEnd(int iRow=-1);
	virtual int GetColStart(UINT col);
	virtual int GetColEnd(UINT col);

	virtual CStdCtrlSkinAttrib GetAttribFinal(UINT col);

	virtual void GenerateName2Cell(std::map<CString, CStdCtrlSkinCell*>& name2cellList);

	virtual void Draw(HDC hDC);

#ifdef __DUMPTEST
	virtual void Dump(std::ofstream& fio, CStdCtrlSkin_EnumDump type) override;
#endif

protected:
	virtual bool LoadXmlNode(CComPtr<IXMLDOMNode> spNode);
};

